/*filename: utils.h*/

#ifndef _UTILS_H_
#define _UTILS_H_

void daemon_init(void);
char* ipaddr2str(u_int32_t ipaddr, char* straddr);
int check_only_one_process(const char* pidfilename);
int str2bytesH(const char* str, unsigned char* data, unsigned int data_len);
int str2bytesH1(const char* str, unsigned char* data, unsigned int data_len);
int bytes2strH(const unsigned char* data, int data_len, char* str);
int isxdigitstr(const char* str);
int isdigitstr(const char* str);
int url_to_hash(const char* url_info_hash, unsigned char* info_hash);
int str_to_hash(const char* url_info_hash, unsigned char* info_hash);
u_int32_t calc_hashnr(const char *key, u_int32_t length);


size_t get_executable_path (char* buffer, size_t len);
int create_dma_dev(const char* dev_name, int major, int minor);

int is_str_ip(const char *sip);
char *str2lower(char *str);
char *str2upper(char *str);

unsigned long get_str_hash(const char *c);
int strcmp_nocase(const char *s1, const char *s2);

void dump_debug_data(const char *data, int data_len, const char *file_name);

void hash2string(char *hash, char *string);

char *trim_domain_string(char *domain);
	
#endif
